package no.monsen.monsenservice.impl;

import no.monsen.monsenservice.*;
import javax.jws.WebService;
import no.monsen.monsenservice.db.MonsenDAO;
import org.apache.log4j.Logger;

/**
 *
 * @author geir.k.wollum
 * 28.02.2008
 */
@WebService(endpointInterface = "no.monsen.monsenservice.MonsenService")
public class MonsenServiceImpl implements MonsenService {

    private Logger log = Logger.getLogger("MonsenServiceImpl");
    private MonsenDAO dao;

    @Override
    public MonsenFact getMonsenFact(MonsenFact request) {
        log.info("Klient ID [" + request.getClientID() + "] kaller");
        dao.addVisitor(request);
        MonsenFact response = dao.getMonsenFact(request.getId());
        return response;
    }

    @Override
    public String isUpdateAvailable(String version) {
        String thisVersion = dao.checkVersion();
        log.info("Klient versjon [" + version + "], Monsen versjon [" + thisVersion + "]");
        return thisVersion;
    }

    public void setMonsenDAO(MonsenDAO dao) {
        this.dao = dao;
    }
}
